<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <!--工具条-->
        <el-form
          :inline="true"
          :model="searchfrom"
          class="toolbar"
          label-position="right"
          label-width="80px"
        >
          <el-row>
            <el-form-item label="账号">
              <el-input v-model="searchfrom.queryString"></el-input>
            </el-form-item>

            <el-form-item label>
              <el-button
                @click="searchUserList"
                type="success"
                style="width: 170px"
                >查询</el-button
              >
            </el-form-item>
            <!-- <el-form-item label>

              <el-button @click="exportExcel()">导出</el-button>
            </el-form-item> -->
          </el-row>
        </el-form>
      </el-row>

      <el-table
        ref="multipleTable"
        :data="userlist"
        border
        stripe
        style="width: 100%"
        @sort-change="changeSort"
        id="out-table"
        tooltip-effect="dark"
        @selection-change="handleSelectionChange"
      >
        <el-table-column prop="contactCode" label="UID"></el-table-column>
        <!-- <el-table-column type="selection"></el-table-column> -->
        <!-- <el-table-column type="index"></el-table-column> -->
        <!-- <el-table-column prop="authName" label="姓名" width="70"></el-table-column> -->
        <!-- <el-table-column
                prop="email"
                label="邮箱">
        </el-table-column>-->
        <!-- <el-table-column prop="email" label="邮箱"></el-table-column> -->
        <el-table-column prop="mobile" label="手机号" width="140"></el-table-column>
        <el-table-column prop="nickName" label="昵称"></el-table-column>

        <el-table-column prop="identityLevel" label="会员等级">
          <template slot-scope="scope">
            <div style="display: flex; align-items: center">
              <span>{{ scope.row.memberLevel }}</span>
              <el-button
                style="margin-left: 40px"
                plain
                size="mini"
                @click="showOtherDialog(scope.row, 1)"
                >修改</el-button
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="identityLevel" label="社区等级">
          <template slot-scope="scope">
            <div style="display: flex; align-items: center">
              <span>{{ scope.row.vipLevel }}</span>
              <!-- {{ getuserLevel(scope.row.vipLevel) }} -->
              <el-button
                style="margin-left: 40px"
                plain
                size="mini"
                @click="showOtherDialog(scope.row, 2)"
                >修改</el-button
              >
            </div>
          </template>
        </el-table-column>
        <!-- sortable="custom" 排序上下小三角 -->
        <el-table-column prop="identityLevel" label="是否实名" width="90">
          <template slot-scope="scope">
            <span>{{ scope.row.isReal == 0 ? "否" : "是" }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="createTime" label="注册时间"></el-table-column>
        <!-- width="170" -->
        <el-table-column label="状态" width="110">
          <template slot-scope="scope">
            <el-tag :type="scope.row.status == 1 ? '' : 'danger'">{{
              getuserStatus(scope.row.status)
            }}</el-tag>
          </template>
          <!-- 让这一行的开关，把状态绑定到 这一行数据的 mg_state 上 -->
          <!-- <el-switch
                    v-model="scope.row.mg_state"
                    @change="(newState) => {switchChanged(newState, scope.row.id)}"
                    slot-scope="scope">
          </el-switch>-->
          <!-- <el-switch
                    v-model="scope.row.mg_state"
                    @change="switchChanged2(scope.row.mg_state, scope.row.id)"
                    slot-scope="scope">
          </el-switch>-->
        </el-table-column>
        <el-table-column label="操作" width="420">
          <template slot-scope="scope">
            <el-button
              type="danger"
              size="mini"
              @click="seeParent(scope.row,1)"
              >上级</el-button>
            <el-button
              type="primary"
              size="mini"
              @click="seeParent(scope.row,2)"
              >下级</el-button>
            <el-button
              type="success"
              size="mini"
              @click="showEditInfoDialog(scope)"
              >资产详情</el-button
            >
            <el-button
              type="info"
              size="mini"
              @click="showZiChanDialog(scope.row)"
              >账单列表</el-button
            >
<el-button
              type="danger"
              v-if="scope.row.status == 2"
              size="mini"
              @click="showEditJiefeng(scope.row)"
              >解封</el-button
            >
            <el-button
              type="primary"
              v-if="scope.row.status == 1"
              size="mini"
              @click="showEditDialog(scope.row)"
              >封号</el-button
            >
            <!-- <el-button type="danger" icon="el-icon-delete" size="mini" @click="remove(scope)"></el-button>
                    <el-tooltip effect="dark" content="分配角色" placement="top" :enterable="false">
                    <el-button type="warning" icon="el-icon-setting" size="mini" @click="showSetRoleDialog(scope.row)"></el-button>
            </el-tooltip>-->
          </template>
        </el-table-column>

        <!-- <el-table-column label="上下级" width="170">
          <template slot-scope="scope">
            <el-button type="danger" size="mini" @click="checkdeng(scope.row.id,1)">上级</el-button>
            <el-button type="success" size="mini" @click="checkdeng(scope.row.id,2)">下级</el-button>

          </template>
        </el-table-column> -->

        <!-- <el-table-column label="操作" width="230">
          <template slot-scope="scope">
            <el-button size="small" @click="checkout(scope.row,1)">CY账单</el-button>
            <el-button size="small" @click="checkout(scope.row,2)">USDT账单</el-button>
          </template>
        </el-table-column> -->
        <!-- <el-table-column label="解除异常封禁" width="140">
          <template slot-scope="scope">
            <el-button type="danger" size="mini" @click="jieerreytu(scope.row)">解除异常</el-button>
          </template>
        </el-table-column> -->
      </el-table>

      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchfrom.pageNo"
        :page-sizes="[2, 5, 10, 15]"
        :page-size="searchfrom.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
    <el-dialog title="账单列表" :visible.sync="dialogTableVisible" width="70%">
      <el-menu
        :default-active="activeIndex"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
      >
        <el-menu-item index="1">BUC</el-menu-item>
        <el-menu-item index="2">USDT</el-menu-item>
        <el-menu-item index="3">BUX</el-menu-item>
        <el-menu-item index="4">积分</el-menu-item>
        <el-menu-item index="5">u积分</el-menu-item>
        <el-table
          ref="multipleTable"
          :data="billList"
          border
          stripe
          style="width: 100%"
          id="out-table"
          tooltip-effect="dark"
        >
          <el-table-column prop="description" label="名称"></el-table-column>
          <el-table-column prop="money" label="数量"></el-table-column>
          <el-table-column prop="createTime" label="时间"></el-table-column>
        </el-table>

        <!-- 分页区域 -->
        <el-pagination
          @size-change="handleSizeChangeOne"
          @current-change="handleCurrentChangeOne"
          :current-page="billfrom.pageNo"
          :page-sizes="[2, 5, 10, 15]"
          :page-size="billfrom.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="billTotal"
        ></el-pagination>
      </el-menu>
    </el-dialog>
    <el-dialog
      title="资产信息"
      :visible.sync="dengdialogTableVisible"
      width="70%"
    >
      <el-table
        ref="multipleTable"
        :data="newZichanList"
        border
        stripe
        style="width: 100%"
        id="out-table"
        tooltip-effect="dark"
      >
        <el-table-column prop="coinName" label="币种名称"></el-table-column>
        <el-table-column prop="balance" label="余额"></el-table-column>
        <el-table-column prop="frozen" label="冻结数量"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="success"
              size="mini"
              @click="saveZichan(scope.row, 1)"
              >增加资产</el-button
            >
            <el-button
              type="danger"
              size="mini"
              @click="saveZichan(scope.row, 2)"
              >减少资产</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog title="正常数据" :visible.sync="dialogTableVisiblenum">
      <el-table :data="gridData">
        <!-- <el-table-column property="userId" label="时间" width="150"></el-table-column> -->
        <el-table-column
          property="createTime"
          label="时间"
          width="150"
        ></el-table-column>
        <el-table-column
          property="billDescription"
          label="类别"
        ></el-table-column>
        <el-table-column property="money" label="数量（CY）"></el-table-column>
        <el-table-column property="balance" label="余额"></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog :title="seeParentTitle" :visible.sync="dialogTableSeeParent">
      <el-table :data="seeParentData">
        <!-- <el-table-column property="userId" label="时间" width="150"></el-table-column> -->
        <el-table-column
          property="nickName"
          label="昵称"
        ></el-table-column>
        <el-table-column property="mobile" label="手机号"></el-table-column>
        <el-table-column property="contactCode" label="uuid"></el-table-column>
        <el-table-column
          property="createTime"
          label="注册时间"
          width="150"
        ></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="封号理由" :visible.sync="dialogFormVisibleLi">
      <el-form :model="form">
        <el-form-item label="理由" :label-width="formLabelWidth">
          <el-input type="textarea" v-model="formLi.queryString"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibleLi = false">取 消</el-button>
        <el-button type="primary" @click="submitLi()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog
      :title="zichanType == 1 ? '增加资产' : '减少资产'"
      :visible.sync="zichanActionBtn"
    >
      <el-form :model="form">
        <el-form-item label="数量" :label-width="formLabelWidth">
          <el-input
            type="input"
            v-model="zichanNum"
            placeholder="请输入数量"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="zichanActionBtn = false">取 消</el-button>
        <el-button type="primary" @click="zichanSubmit()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="修改会员等级" :visible.sync="huiyuanBtn">
      <el-form :model="form">
        <el-form-item label="会员等级" label-width="100">
          <el-input
            type="input"
            v-model="huiyuanLevel"
            placeholder="请输入会员等级"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="huiyuanBtn = false">取 消</el-button>
        <el-button type="primary" @click="saveHuiyuan()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="修改社区等级" :visible.sync="shequBtn">
      <el-form :model="form">
        <el-form-item label="社区等级" label-width="100">
          <el-input
            type="input"
            v-model="shequLevel"
            placeholder="请输入社区等级"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="shequBtn = false">取 消</el-button>
        <el-button type="primary" @click="saveShequ()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import FileSaver from "file-saver";
import XLSX from "xlsx";
export default {
  name: "DrugInformation",
  data() {
    return {
      textbutton: "发送验证码",
      addjinform: {
        queryString: "",
        numbers: "",
        password: "",
      },
      disabledto: false,
      dialogFormVisibleadd: false,
      dialogFormVisibleLi: false,
      gridData: [],
      dialogTableVisiblenum: false,
      dialogTableVisible: false,
      dengdialogTableVisible: false,
      titlename: "",
      formLi: {
        queryId: "",
        queryString: "",
        queryType: 1,
      },
      seeParentTitle:"",
      dialogTableSeeParent:false,
      seeParentData:[],
      gridDatadeng: "",
      value1: "",
      userlist: [],
      billfrom: {
        pageNo: 1,
        pageSize: 10,
        userId: "",
        queryId: 1, //币种id
      },
      billTotal: 0,
      billList: [],
      searchfrom: {
        sortName: "",
        isAsc: 0,
        createDate: "",
        status: -1,
        password: "",
        queryString: "",
        queryType: 0,
        pageNo: 1,
        pageSize: 10,
        level: "",
      },
      total: 0,
      isAgainOrder: [
        {
          name: "请选择",
          status: -1,
        },
        {
          name: "封号",
          status: 0,
        },
        {
          name: "正常",
          status: 1,
        },
      ],
      isshiMIng: [
        {
          name: "请选择",
          status: 0,
        },
        {
          name: "已实名",
          status: 1,
        },
        {
          name: "未实名",
          status: 2,
        },
      ],
      teaTreelist: [],
      TreelgridData: [],
      multipleSelection: [],

      verification: 60,
      timer: null,
      count: "",
      pushContent: "",

      activeIndex: "1",
      newZichanList: [],
      zichanType: null,
      zichanActionBtn: false,
      zichanNum: "",
      currentIndex: null,
      userId: "",
      coinId: "",
      huiyuanBtn: false,
      huiyuanLevel: "",
      shequBtn: false,
      shequLevel: "",
    };
  },
  created() {
    this.getuserlist();
  },
  methods: {
    seeParent(row,type){
      this.$http
        .post("/manage/user/parentChild", {
          queryId: row.id,
          queryType: type,
        })
        .then((res) => {
          if (res.data.status == 1) {
            let str=type==1?"上级":"下级";
            if(res.data.data[0]==null){
                  this.$message({
                    message: "当前用户暂无"+str,
                    type: "success",
                  });
            }else{
              this.dialogTableSeeParent=true;
              this.seeParentTitle=row.nickName+"的"+str;
              this.seeParentData=res.data.data;
            }
          } else {
            this.$message({
              message: res.data.message,
              type: "success",
            });
          }
        });
    },
    showOtherDialog(data, type) {
      this.userId = data.id;
      if (type == 1) {
        this.huiyuanLevel = data.memberLevel;
        this.huiyuanBtn = true;
      } else if (type == 2) {
        this.shequLevel = data.vipLevel;
        this.shequBtn = true;
      }
    },
    saveHuiyuan() {
      this.$http
        .post("/manage/user/editMemberLevel", {
          queryId: this.huiyuanLevel,
          userId: this.userId,
        })
        .then((res) => {
          if (res.data.status == 1) {
            this.getuserlist();
            this.huiyuanBtn = false;
            this.$message({
              message: "修改成功",
              type: "success",
            });
          } else {
            this.$message({
              message: res.data.message,
              type: "success",
            });
          }
        });
    },
    saveShequ() {
      this.$http
        .post("/manage/user/editTeamLevel", {
          queryId: this.shequLevel,
          userId: this.userId,
        })
        .then((res) => {
          if (res.data.status == 1) {
            this.getuserlist();
            this.shequBtn = false;
            this.$message({
              message: "修改成功",
              type: "success",
            });
          } else {
            this.$message({
              message: res.data.message,
              type: "success",
            });
          }
        });
    },
    saveZichan(data, type) {
      console.log(data);
      this.coinId = data.coinId;
      this.zichanNum = "";
      this.zichanType = type;
      this.zichanActionBtn = true;
    },
    zichanSubmit() {
      if (this.zichanNum) {
        this.$http
          .post("/manage/user/addUserCoin", {
            queryType: this.zichanType,
            numbers: this.zichanNum,
            queryId: this.coinId,
            userId: this.userId,
          })
          .then((res) => {
            if (res.data.status == 1) {
              this.getuserlist(2);
              this.zichanActionBtn = false;
              this.$message({
                message: this.zichanType == 1 ? "资产添加成功" : "资产减少成功",
                type: "success",
              });
            } else {
              this.$message({
                message: res.data.message,
                type: "success",
              });
            }
          });
      }
    },
    showEditInfoDialog(data) {
      console.log(data);

      this.currentIndex = data.$index;
      this.userId = data.row.id;
      this.newZichanList = data.row.userCoins;
      this.dengdialogTableVisible = true;
    },
    showZiChanDialog(data) {
      console.log(data);
      this.billfrom.userId = data.id;
      this.billfrom.pageNo = 1;
      this.getBillList();
      this.dialogTableVisible = true;
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      this.activeIndex = keyPath[0];
      if (key == 4) {
        this.billfrom.queryId = 9;
      } else if(key == 5) {
        this.billfrom.queryId = 10;
      }else{
        this.billfrom.queryId = key;
      }
      this.billfrom.pageNo = 1;
      this.getBillList();
    },
    // 60s 倒计时
    getsubmitadd() {
      // console.log(this.addjinform)
      this.$http
        .post("/manage/userCoin/userAddCoin", this.addjinform)
        .then((res) => {
          if (res.data.status == 1) {
            this.getuserlist();
            this.$message({
              message: "添加成功",
              type: "success",
            });
          } else {
            this.getuserlist();
            this.$message({
              message: "添加失败",
              type: "success",
            });
          }
        });
    },
    countDown() {
      var timeCount = 60;
      if (!this.timer) {
        this.count = timeCount;
        // console.log(this.count);
        //  this.show = false;
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= timeCount) {
            this.count--;
            this.textbutton = "剩余" + this.count + "s";
          } else {
            //  this.show = true;
            // this.dis = false;
            clearInterval(this.timer);
            this.textbutton = "重新获取";
            this.disabledto = false;
            this.timer = null;
          }
        }, 1000);
      }
    },

    submitAdd() {
      console.log(this.multipleSelection);
      let value = "";
      for (var i = 0; i < this.multipleSelection.length; i++) {
        if (i > 0) {
          //最开始为“，”,i>.0去除最开始的逗号
          value += ",";
        }
        //json[i][key]相当于json[i].key，但此处key为参数，值不明确，所以只能使用json[i][key]这种方式表达**
        value += this.multipleSelection[i]["id"];
      }
      // return value
      console.log(value);
      // POST
      // this.$http.post('/manage/userCoin/userAddCoin',)
      this.addjinform.queryString = value;
      this.dialogFormVisibleadd = true;
    },
    getcode() {
      if (this.addjinform.numbers == "") {
        this.$message({
          message: "数量不能为空",
          type: "success",
        });
      } else {
        // console.log(1)
        this.disabledto = true;
        // this.countDown();
        this.$http.post("/manage/conf/sendSmsCode", {}).then((res) => {
          //   this.excharge = res.data.data;
          console.log(res);
          if (res.data.status == 1) {
            this.countDown();

            this.$message({
              message: "短信验证码发送成功",
              type: "success",
            });
          } else {
            this.disabledto = false;
            this.$message({
              message: "短信验证码发送失败",
              type: "info",
            });
          }
        });
      }
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      console.log(val);
      this.multipleSelection = val;
    },

    exportExcel() {
      this.searchfrom.pageSize = this.total;
      console.log(this.searchfrom.pageSize);
      this.handleSizeChange1("open");
      /* out-table关联导出的dom节点 */
      var wb = XLSX.utils.table_to_book(document.querySelector("#out-table"));
      /* get binary string as output */
      var wbout = XLSX.write(wb, {
        bookType: "xlsx",
        bookSST: true,
        type: "array",
      });
      try {
        FileSaver.saveAs(
          new Blob([wbout], { type: "application/octet-stream" }),
          "药品信息.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, wbout);
      }
      //❤恢复之前的pageSize-每页条数的值，还原表格
      setTimeout(() => {
        this.handleSizeChange1("close");
      }, 1000);
      return wbout;
    },
    handleSizeChange1(val) {
      if (val == "open") {
        this.searchfrom.pageSize = this.total;
        setTimeout(() => {
          this.exportExcel();
        }, 1000);
      } else if (val == "close") {
        this.searchfrom.pageSize = 20;
        this.pageNo = 1;
      } else {
        this.searchfrom.pageSize = val;
        this.pageNo = 1;
      }
      console.log();
      // this.getuserlist();
    },
    checkdeng(row, type) {
      this.titlename = type == 1 ? "上级" : "下级";
      console.log(this.titlename);
      this.$http
        .post("/manage/admin/userUpAndDown", {
          userId: row,
          queryType: type,
        })
        .then((res) => {
          // console.log(res);

          this.dengdialogTableVisible = true;
          this.gridDatadeng = res.data.data;
          console.log(this.gridDatadeng);
        });
    },

    gettreename(id) {
      let re = "";
      this.teaTreelist.forEach((obj) => {
        if (obj.id == id) {
          // console.log(obj.treeName)
          re = obj.treeName;
          return;
        }
      });
      return re;
    },

    check(row) {
      this.dialogTableVisible = true;
      this.$http
        .post("/manage/admin/userTeaTree", {
          userId: row,
        })
        .then((res) => {
          console.log(res);
          if (res.data.status == 1) {
            // this.$message({
            //   message: "解封成功",
            //   type: "success"
            // });
            // this.getuserlist();
            this.TreelgridData = res.data.data;
          }
        });
    },
    getuserLevel(row) {
      return "V" + row;
    },
    // 从后台获取数据,重新排序
    changeSort(val) {
      console.log(val); // column: {…} order: "ascending" prop: "date"
      // 根据当前排序重新获取后台数据,一般后台会需要一个排序的参数
      if (val.order == "ascending") {
        this.searchfrom.isAsc = 1;
        if (val.prop == "money") {
          this.searchfrom.sortName = "c." + val.prop;
        } else {
          this.searchfrom.sortName = "u." + val.prop;
          console.log(this.searchfrom.sortName);
        }

        this.getuserlist();
      } else if (val.order == "descending") {
        this.searchfrom.isAsc = 0;
        if (val.prop == "money") {
          this.searchfrom.sortName = "c." + val.prop;
        } else {
          this.searchfrom.sortName = "u." + val.prop;
        }
        console.log(this.searchfrom.sortName);
        this.getuserlist();
      }
    },
    formatTime(dateTime, format = "yyyy-MM-dd") {
      if (!dateTime) return dateTime;
      let args = {
        "M+": dateTime.getMonth() + 1,
        "d+": dateTime.getDate(),
        "h+": dateTime.getHours(),
        "m+": dateTime.getMinutes(),
        "s+": dateTime.getSeconds(),
        "q+": Math.floor((dateTime.getMonth() + 3) / 3), //quarter
        S: dateTime.getMilliseconds(),
      };
      if (/(y+)/.test(format))
        format = format.replace(
          RegExp.$1,
          (dateTime.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
      for (var i in args) {
        let n = args[i];
        if (new RegExp("(" + i + ")").test(format))
          format = format.replace(
            RegExp.$1,
            RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length)
          );
      }
      console.log(format);
      return format;
      // this.refreshData(format);
    },
    // POST
    showEditJiefeng(row) {
      this.$confirm("请确认要是否要解封, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //   this.$message({
          //     type: 'success',
          //     message: '删除成功!'
          //   });
          // POST /manage/admin/userDisabled
          this.$http
            .post("/manage/user/userDisabled", {
              queryId: row.id,
              queryType: 2,
            })
            .then((res) => {
              // console.log(res)
              if (res.data.status == 1) {
                this.$message({
                  message: "解封成功",
                  type: "success",
                });
                this.getuserlist();
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    getuserStatus(type) {
      if (type == 1) {
        return "正常";
      } else if (type == 2) {
        return "封号";
      }
    },
    submitLi() {
      this.$confirm("请确认是否要封号, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http
            .post("/manage/user/userDisabled", this.formLi)
            .then((res) => {
              // console.log(res)
              if (res.data.status == 1) {
                this.$message({
                  message: "封号成功",
                  type: "success",
                });
                this.dialogFormVisibleLi = false;
                this.getuserlist();
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    showEditDialog(row) {
      console.log(row);
      this.formLi.queryId = row.id;
      this.dialogFormVisibleLi = true;
    },
    getuserlist(type) {
      this.$http.post("/manage/user/userList", this.searchfrom).then((res) => {
        // console.log(res)
        if (res.data.status == 1) {
          this.userlist = res.data.data.list;
          this.total = res.data.data.total;
          if (type == 2) {
            this.newZichanList =
              res.data.data.list[this.currentIndex].userCoins;
          }
        }
      });
    },
    getBillList() {
      this.$http
        .post("/manage/user/userBillList", this.billfrom)
        .then((res) => {
          // console.log(res)
          if (res.data.status == 1) {
            this.billList = res.data.data.list;
            this.billTotal = res.data.data.total;
          }
        });
    },
    searchUserList() {
      this.searchfrom.createDate = this.formatTime(this.value1);
      this.searchfrom.pageNo = 1;
      this.getuserlist();
    },
    // 监听 pagesize 的变化
    handleSizeChange(newSize) {
      // 把最新的 pagesize 赋值给 this.queryinfo
      this.searchfrom.pageSize = newSize;
      this.getuserlist();
    },
    // 监听 页码值 的变化
    handleCurrentChange(newPageNum) {
      console.log(newPageNum);
      this.searchfrom.pageNo = newPageNum;
      this.getuserlist();
    },
    // 监听 pagesize 的变化
    handleSizeChangeOne(newSize) {
      // 把最新的 pagesize 赋值给 this.queryinfo
      this.billfrom.pageSize = newSize;
      this.billList();
    },
    // 监听 页码值 的变化
    handleCurrentChangeOne(newPageNum) {
      console.log(newPageNum);
      this.billfrom.pageNo = newPageNum;
      this.billList();
    },
  },
};
</script>
